package com.qf.ex;

import com.qf.utils.Result;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class MyHandelException {

    @ExceptionHandler({
            CustomException.class
    })
    //处理自定义的异常
    public Result handelCustomException(CustomException e){
        e.printStackTrace();
        return Result.error(e.getMessage());

    }


    @ExceptionHandler({
            UnauthorizedException.class
    })

    //处理认证失败或没有权限的异常
    public Result UnauthorizedException(UnauthorizedException e){
        e.printStackTrace();
        return Result.error("认证失败");
    }


    @ExceptionHandler({
        Exception.class
    })
    public Result OtherException(Exception e){
        e.getMessage();
        return Result.error("系统异常，请联系管理员");
    }
}
